<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<x:parse xml="${param.xmlstr}" var="xmlData" />
<div class="t_bar">
	 <span class="color_red">*</span>主要完成单位情况
</div>

<table id="organizations" class="table01" border="0" width="100%"
	cellspacing="0" cellpadding="0">
	<thead>
		<tr>
			<th width="5%" align="center">选择</th>
			<th width="7%" align="center">序号</th>
			<th width="20%" align="center">单位名称</th>
			<th width="17%" align="center">联系人</th>
			<th width="17%" align="center">单位电话</th>
			<th width="17%" align="center">邮箱</th>
			<th width="17%" align="center">传真</th>
		</tr>
	</thead>
	<tbody>
		<tr style="display: none">
			<td align="center"><input type="radio" name="organizations_seq" onclick="setSubmitPsn2();"/></td>
			<td align="center"><span name="organizations|organization[0]@seq_no">[index]</span></td>
			<td align="center"><span name="organizations|organization[0]|org_name" label="单位名称"></span></td>
			<td align="center"><span name="organizations|organization[0]|contact_name" label="联系人"></span></td>
			<td align="center"><span name="organizations|organization[0]|org_tel" label="单位电话"></span></td>
			<td align="center"><span name="organizations|organization[0]|email" label="邮箱"></span></td>
			<td align="center"><span name="organizations|organization[0]|fax2" label="传真"></span></td>
			<input type="hidden" name="organizations|organization[0]|zip_code" label="邮编" />
			<input type="hidden" name="organizations|organization[0]|nature_name" label="单位性质" />
			<input type="hidden" name="organizations|organization[0]|nature_value" label="单位性质" />
			<input type="hidden" name="organizations|organization[0]|address" label="通讯地址" />
			<input type="hidden" name="organizations|organization[0]|main_contribution2" label="主要贡献" />
			<input type="hidden" name="organizations|organization[0]|main_contribution2_hidden" label="主要贡献2" />
			
			
			<input type="hidden" name="organizations|organization[0]|faren_name" label="法定代表人" />
			<input type="hidden" name="organizations|organization[0]|contact_mobile" label="移动电话" />
		</tr>
		<c:set value="0" var="index" scope="page" />
		<x:forEach select="$xmlData/data/organizations/organization" var="situation">
			<c:choose>
				<c:when test="${index<10}">
					<c:set value="0" var="flag" scope="page" />
				</c:when>
				<c:otherwise>
					<c:set value="" var="flag" scope="page" />
				</c:otherwise>
			</c:choose>
			<tr>
				<td align="center"><input type="radio" onclick="setSubmitPsn2();" name="organizations_seq" />
					<c:if test="${index==0}">
						<input type="hidden" id="submit_psn" name="organizations/organization[${flag}${index}]@submit_psn" value="1" />
						<%-- <input type="hidden"
							name="organizations/organization[${flag}${index}]/contact_name"
							value="<x:out select="$situation/contact_name" />" /> --%>
					</c:if></td>
				<td align="center">
					<span name="organizations/organization[${flag}${index}]@seq_no">${index+1}</span>
				</td>
				<td align="center">
					<span label="单位名称" class="required " name="organizations/organization[${flag}${index}]/org_name">
						<x:out select="$situation/org_name" />
					</span>
				</td>
				<td align="center">
					<span label="联系人" class="required " name="organizations/organization[${flag}${index}]/contact_name">
						<x:out select="$situation/contact_name" /> 
					</span>
				</td>
				<td align="center">
					<span label="单位电话" class="required " name="organizations/organization[${flag}${index}]/org_tel">
						<x:out select="$situation/org_tel" />
					</span>
				</td>
				<td align="center">
					<span label="邮箱" class="required " name="organizations/organization[${flag}${index}]/email">
						<x:out select="$situation/email" />
					</span>
				</td>
				<td align="center">
					<span label="传真" class=" required" name="organizations/organization[${flag}${index}]/fax2">
						<x:out select="$situation/fax2" />
					</span>
				</td>
				<input type="hidden" label="单位性质" class="required " name="organizations/organization[${flag}${index}]/nature_name"
					value="<x:out select="$situation/nature_name" />" />
				<input type="hidden" label="单位性质"  name="organizations/organization[${flag}${index}]/nature_value"
					value="<x:out select="$situation/nature_value" />" />
				<input type="hidden" label="邮编" class="required " name="organizations/organization[${flag}${index}]/zip_code"
					value="<x:out select="$situation/zip_code" />" />
				<input type="hidden" label="地址" class="required " name="organizations/organization[${flag}${index}]/address"
					value="<x:out select="$situation/address" />" />
				<input type="hidden" label="主要贡献" class="required " name="organizations/organization[${flag}${index}]/main_contribution2"
					value="<x:out select="$situation/main_contribution2" />" />
				<input type="hidden" label="主要贡献 hidden" name="organizations/organization[${flag}${index}]/main_contribution2_hidden"
					value="<x:out select="$situation/main_contribution2_hidden" />" />
					
					
				<input type="hidden" label="法定代表人"  class="required " name="organizations/organization[${flag}${index}]/faren_name"
					value="<x:out select="$situation/faren_name" />" />
				<input type="hidden" label="移动电话"  class="required " name="organizations/organization[${flag}${index}]/contact_mobile"
					value="<x:out select="$situation/contact_mobile" />" />
					
			</tr>
			<c:set value="${index+1}" var="index" scope="page" />
		</x:forEach>

	</tbody>

</table>

<br />
<table border="0" cellpadding="0" cellspacing="1" class="table01"
	id="total">
	<col style="width: 20%" />
	<col style="width: 80%" />
	<tr>
		<td colspan="2"><input class="button_02" type="button" value="添加"
			onclick="if(checkTabLimit('organizations',5,'最多只能填写5条')){addNewRow('organizations','${ctx}/proposal/2014/edit/dialog/orgInfoEdit_kxjstjs_dgzywcdw_2016?parentTab=organizations&type=add&needMeetingInfo=${param.needMeetingInfo}&TB_iframe=true&height=440&width=900','添加主要完成单位情况');}try{top.resizeFrame();}catch(e){};" />
			<input class="button_02" id="prev_org" type="button" value="上移"
			onclick="movePrev('organizations','organizations_seq');setSubmitPsn2();showOrgName();" />
			<input class="button_02" id="next_org" type="button" value="下移"
			onclick="moveNext('organizations','organizations_seq');setSubmitPsn2();showOrgName();" />
			<input class="button_02" id="zh_psnEdit" type="button" value="编辑"
			onclick="editRow('organizations','${ctx}/proposal/2014/edit/dialog/orgInfoEdit_kxjstjs_dgzywcdw_2016?parentTab=organizations&type=edit&needMeetingInfo=${param.needMeetingInfo}&TB_iframe=true&height=440&width=900','编辑主要完成单位情况')">

			<input class="button_02" id="del_org" type="button" value="删除"
			onclick="deleteSelectedRow('organizations','完成单位信息');showTable1();showOrgName();" /></td>
	</tr>
</table>




<script type="text/javascript">
$(document).ready(function(){
	showTable1();
	showOrgName();
})

function showTable1(){
	var text= $("#organizations").find("tr:last").find("span[name$='@seq_no']").text();
	   text = parseInt(text);
	   if (text >= 2){
		   $("#text2").show();
	   }else{
		   $("#text2").hide();
		   }
}



function showOrgName(){
	var i = 0;
	var t = 0;
	var OrgName="";
	for(i;i <= 10;i++){
		var OrgNameSmall="";
		if(i<=9){
			i="0" +i;
		}
		if(t==0){OrgNameSmall=$("span[name='organizations/organization["+i+"]/org_name']").text();}
		
		if($("span[name='organizations/organization["+i+"]/org_name']").text() != "" && $("span[name='organizations/organization["+i+"]/org_name']").text() != null)
		{
			if(t>0){OrgNameSmall= "、" + $("span[name='organizations/organization["+i+"]/org_name']").text();}
		}
		OrgName=OrgName + OrgNameSmall;
	
		$("#main_finish_org").text(OrgName);
		
		t++;
	}
}










</script>

<div id="text2" style="display: none">
<div class="t_bar"><span class="color_red">*</span>完成单位合作关系说明（限1500字）</div>
<table class="t_css" width="100%" border="0" cellpadding="0" id="uint_cooperation_introduction" cellspacing="1" style="table-layout:fixed;">
	<col width="20%;"/>
	<col width="25%;"/>
	<col width="20%;"/>
	<col width="20%;"/>
	<col width="25%;"/>
	<tr class="li_2">
		<td  colspan="5" >
			<textarea rows="10" style="width: 888px;" name='proposal/uint_cooperation_relationship_introduction' class="input_textarea required maxlength:1500"   label="完成单位合作关系说明"><x:out select="$xmlData/data/proposal/uint_cooperation_relationship_introduction"/></textarea>
	      <input type='hidden' name='proposal/uint_cooperation_relationship_introduction_hidden' id='uint_cooperation_relationship_introduction_hidden' value=''>
		</td>
	</tr>
</table>
</div>























<script type="text/javascript">

	/**
	 * 锁定申报人行的按钮
	 */
	/* 
	 $(document).ready(function() {
	 setSubmitPsn2();
	 }); */

	function setSubmitPsn2() {

		/* 		if ($("#organizations :radio:checked").length == 0) {
		 scmWarn('请选择一行!');
		 return false;
		 } */
		var tr = $("#organizations :radio:checked").parents("tr");
		if(tr.length == 0){
			return false;
		}
		//alert(tr.get(0).rowIndex - 1);

		if (tr.get(0).rowIndex - 1 == 1) {// 如果选择的是申报人
			$("#prev_org").attr("disabled", "true").css("color", "#808080");
			$("#next_org").attr("disabled", "true").css("color", "#808080");
			$("#del_org").attr("disabled", "true").css("color", "#808080");

		} else if (tr.get(0).rowIndex - 1 == 2) {// 如果是申报书的下一行
			$("#prev_org").attr("disabled", "true").css("color", "#808080");
			$("#next_org").removeAttr("disabled").css("color", "#003366");
			$("#del_org").removeAttr("disabled").css("color", "#003366");

		} else {
			$("#prev_org").removeAttr("disabled").css("color", "#003366");
			$("#next_org").removeAttr("disabled").css("color", "#003366");
			$("# del_org").removeAttr("disabled").css("color", "#003366");
		} 

	}
</script>




